<template>
  <a-modal :title="title" :visible="visible" @cancel="handleCancel" :destroyOnClose="true">
    <a-form-model ref="form" :model="queryParam">
      <a-form-model-item label="上传附件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fileNameList">
        <!-- <NKUpload ref="fileUpload" :fileid="'file'" @uploadFile="handleFileUploaded"></NKUpload> -->
        <RuleUpload
          v-if="visible"
          ref="fileUpload"
          :fileid="fid"
          :isShow="isShow"
          @uploadFile="handleSubmit"
        ></RuleUpload>
      </a-form-model-item>
    </a-form-model>

    <!-- <template v-if="title != '详情'" slot="footer">
      <a-button @click="handleCancel">取消</a-button>
      <a-button type="primary" @click="saveData(0)">保存</a-button>
      <a-button type="primary" @click="saveData(1)">提交</a-button>
    </template> -->

    <template slot="footer">
      <a-button @click="handleCancel">关闭</a-button>
      <a-button type="primary" @click="saveData()">提交</a-button>
    </template>
  </a-modal>
</template>

<script>
import moment from 'moment'
import { httpAction, getAction, postAction, deleteAction } from '@/api/manage'
// import NKUpload from './components/NKUpload.vue'
import RuleUpload from '../../../components/RuleUpload.vue'
export default {
  name: 'FileModel',
  components: { RuleUpload },
  data() {
    return {
      title: '文件上传',
      queryParam: {},
      visible: false,
      isShow: false,
      disableSubmit: true,
      fileData: [],
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      approverList: '',
      url: {
        file: '/incon/inconReviewPlan/queryFileList',
      },
      fid: '',
    }
  },
  created() {},
  mounted() {},
  methods: {
    saveData(type) {
      this.$refs.fileUpload.saveFile()
    },
    handleSubmit(id) {
      // console.log(this.queryParam, 'query')
      this.fid = id
      this.$emit('openModelView', id)
    },
    async handleFileAdd(planId, fileType) {
      const data = await postAction(
        `/incon/inconReviewPlan/saveFileInfo?planId=${planId}&fid=${this.fid}&fileType=${fileType}`
      )
      if (+data.code == 200) {
        this.visible = false
        this.$refs.fileUpload.setFile([])
      }
    },
    handleCancel(e) {
      this.queryParam = {
        year: '',
      }
      this.visible = false
    },
    moment,
    // getFileList(record, type) {
    //   // ${record.status}
    //   getAction(`${this.url.file}?planId=${record.id}&fileType=${type}`).then((res) => {
    //     if (+res.code == 200) {
    //       this.$refs.fileUpload.setFile(res.result.records)
    //     }
    //   })
    // },
    // 弹出日历和关闭日历的回调
    handleOpenChange(status) {
      this.yearPickShow = status
    },
    look(record, type) {
      // console.log(record, 'record')
      // this.getFileList(record, type)
      this.visible = true
    },
  },
}
</script>

<style scoped>
</style>
